package com.huawei.appgallery.game.impl;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import o.cle;
import o.clg;
import o.cln;
import o.dgh;
import o.dhq;
import o.ContentManager;

public class Provider extends ContentProvider {
    public int delete(Uri uri, String str, String[] strArr) {
        return 0;
    }

    public String getType(Uri uri) {
        return "";
    }

    public Uri insert(Uri uri, ContentValues contentValues) {
        return null;
    }

    public boolean onCreate() {
        return false;
    }

    public Cursor query(Uri uri, String[] strArr, String str, String[] strArr2, String str2) {
        return null;
    }

    public int update(Uri uri, ContentValues contentValues, String str, String[] strArr) {
        return 0;
    }

    public Bundle call(String str, String str2, Bundle bundle) {
        if (!dhq.ॱ().ˎ()) {
            cle.ˎ.ˋ("GameResourcePreLoad", " not agree protocol forever,finish!");
            return null;
        } else if (!str.equals("submitUpdateResult")) {
            return null;
        } else {
            int i = bundle.getInt(HiAnalyticsConstant.BI_KEY_RESUST, -1);
            cle.ˎ.ˋ("GameResourcePreLoad", "provider.submitUpdateResult:" + i);
            int ˏ = ˏ(i);
            Bundle bundle2 = new Bundle();
            bundle2.putInt("returnCode", ˏ);
            return bundle2;
        }
    }

    private int ˏ(int i) {
        if (!cln.ʼ()) {
            return 1;
        }
        String callingPackage = getCallingPackage();
        GameResource ˊ = clg.ˏ().ˊ(callingPackage);
        if (ˏ(ˊ)) {
            ˊ(ˊ.ॱ());
            ˊ.ˏ(i == 0 ? 6 : 7);
            clg.ˏ().ˎ(ˊ);
            ˋ(ˊ, i);
            cle.ˎ.ˋ("GameResourcePreLoad", "submitUpdateResult finished, result=" + i + ", package=" + callingPackage);
            return 0;
        }
        cle.ˎ.ˏ("GameResourcePreLoad", "checkSignature failed, package=" + callingPackage);
        return 1;
    }

    private boolean ˏ(GameResource gameResource) {
        if (gameResource != null) {
            return ˊ(ॱ(ContentManager.getInstant().getContext(), gameResource.ॱ()), ˋ(gameResource));
        }
        cle.ˎ.ˏ("GameResourcePreLoad", "checkSignature: gameResource is null");
        return false;
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private java.util.List<java.lang.String> ॱ(android.content.Context r10, java.lang.String r11) {
        /*
        r9 = this;
        r0 = 0;
        r3 = new java.util.ArrayList;
        r3.<init>();
        r1 = r10.getPackageManager();	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r2 = 0;
        r1.getPackageInfo(r11, r2);	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r2 = 64;
        r1 = r1.getPackageInfo(r11, r2);	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r4 = r1.signatures;	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r5 = r4.length;	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r2 = r0;
    L_0x0018:
        if (r2 >= r5) goto L_0x0086;
    L_0x001a:
        r0 = r4[r2];	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r1 = 0;
        if (r0 == 0) goto L_0x0044;
    L_0x001f:
        r0 = r0.toCharsString();	 Catch:{ Exception -> 0x0048, NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087 }
        r0 = o.doa.ˊ(r0);	 Catch:{ Exception -> 0x0048, NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087 }
        r0 = o.dnk.ˏ(r0);	 Catch:{ Exception -> 0x0048, NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087 }
        r0 = o.eux.ॱ(r0);	 Catch:{ Exception -> 0x0048, NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087 }
    L_0x002f:
        if (r0 == 0) goto L_0x0044;
    L_0x0031:
        r1 = r0.trim();	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r1 = r1.length();	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        if (r1 <= 0) goto L_0x0044;
    L_0x003b:
        r1 = java.util.Locale.US;	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r0 = r0.toUpperCase(r1);	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r3.add(r0);	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
    L_0x0044:
        r0 = r2 + 1;
        r2 = r0;
        goto L_0x0018;
    L_0x0048:
        r0 = move-exception;
        r6 = "GameResourcePreLoad";
        r7 = new java.lang.StringBuilder;	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r7.<init>();	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r8 = "getSign, Exception: ";
        r7 = r7.append(r8);	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r0 = r0.getMessage();	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r0 = r7.append(r0);	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r0 = r0.toString();	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        o.dna.ˏ(r6, r0);	 Catch:{ NameNotFoundException -> 0x0067, UnsupportedOperationException -> 0x0087, Exception -> 0x00a7 }
        r0 = r1;
        goto L_0x002f;
    L_0x0067:
        r0 = move-exception;
        r1 = o.cle.ˎ;
        r2 = "GameResourcePreLoad";
        r4 = new java.lang.StringBuilder;
        r4.<init>();
        r5 = "getSign exception:";
        r4 = r4.append(r5);
        r0 = r0.getMessage();
        r0 = r4.append(r0);
        r0 = r0.toString();
        r1.ˎ(r2, r0);
    L_0x0086:
        return r3;
    L_0x0087:
        r0 = move-exception;
        r1 = o.cle.ˎ;
        r2 = "GameResourcePreLoad";
        r4 = new java.lang.StringBuilder;
        r4.<init>();
        r5 = "getSign exception:";
        r4 = r4.append(r5);
        r0 = r0.getMessage();
        r0 = r4.append(r0);
        r0 = r0.toString();
        r1.ˎ(r2, r0);
        goto L_0x0086;
    L_0x00a7:
        r0 = move-exception;
        r1 = o.cle.ˎ;
        r2 = "GameResourcePreLoad";
        r4 = new java.lang.StringBuilder;
        r4.<init>();
        r5 = "getSign exception:";
        r4 = r4.append(r5);
        r0 = r0.getMessage();
        r0 = r4.append(r0);
        r0 = r0.toString();
        r1.ˎ(r2, r0);
        goto L_0x0086;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.appgallery.game.impl.Provider.ॱ(android.content.Context, java.lang.String):java.util.List<java.lang.String>");
    }

    private List<String> ˋ(GameResource gameResource) {
        List<String> arrayList = new ArrayList();
        if (gameResource.ˋ() != null && gameResource.ˋ().length() > 0) {
            for (Object add : gameResource.ˋ().split(",")) {
                arrayList.add(add);
            }
        }
        return arrayList;
    }

    private boolean ˊ(List<String> list, List<String> list2) {
        for (String str : list) {
            for (String equalsIgnoreCase : list2) {
                if (str.equalsIgnoreCase(equalsIgnoreCase)) {
                    return true;
                }
            }
        }
        return false;
    }

    private void ˊ(String str) {
        if (cln.ᐝ()) {
            File[] listFiles = new File(cln.ॱ(str)).listFiles();
            if (listFiles != null) {
                for (File ˋ : listFiles) {
                    cln.ˋ(ˋ);
                }
            }
        }
    }

    private void ˋ(GameResource gameResource, int i) {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(KeyAndValue.NUMBER_01).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(gameResource.ॱ()).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(gameResource.ˎ()).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(i);
        dgh.ॱ(ContentManager.getInstant().getContext(), "320106", stringBuffer.toString());
    }
}
